package com.bzkj.web.controller.basic;

import com.bzkj.basicinfo.domain.basic.BasicPicInfo;
import com.bzkj.basicinfo.service.basic.BasicPicInfoService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "图标管理")
@RestController
@RequestMapping("basic/picInfo")
public class BasicPicInfoController extends BaseController {
    @Autowired
    private BasicPicInfoService basicPicInfoService;

    /**
     * 条件查询图标信息
     *
     * @param entity
     * @return
     */
    @ApiOperation("查询接口")
    @GetMapping("findBasicPicInfoList")
    public TableDataInfo findBasicPicInfoList(BasicPicInfo entity) {
        startPage();
        return getDataTable(basicPicInfoService.findBasicPicInfoList(entity));
    }

    /**
     * 查询所有图片接口（下拉使用）
     * @param entity
     * @return
     */
    @ApiOperation("查询接口")
    @GetMapping("/findAllBasicPicInfoList")
    public AjaxResult findAllBasicPicInfoList(BasicPicInfo entity) {
        return AjaxResult.success(basicPicInfoService.findBasicPicInfoList(entity));
    }

    /**
     * 保存图标信息
     *
     * @param entity
     * @return
     */
    @ApiOperation("新增接口")
    @PostMapping("basicPicInfoSave")
    @LogC(title = "ncc图标信息", businessType = BusinessType.INSERT,
            tableNames = "basic_pic_info", pkFieldNames = "pic_class_id", content = "' 图标名称：'+#entity.picClassName")
    public AjaxResult basicPicInfoSave(@RequestBody BasicPicInfo entity) {
        return basicPicInfoService.basicPicInfoSave(entity);
    }

    /**
     * 修改图标信息
     */
    @ApiOperation("修改接口")
    @PutMapping("basicPicInfoUpdate")
    @LogC(title = "ncc图标信息", businessType = BusinessType.UPDATE,
            tableNames = "basic_pic_info", pkFieldNames = "pic_class_id", content = "' 图标名称：'+#entity.picClassName")
    public AjaxResult basicPicInfoUpdate(@RequestBody BasicPicInfo entity){
        return basicPicInfoService.basicPicInfoUpdate(entity);
    }
    @DeleteMapping("/delete")
    public AjaxResult deleteById(String id){
        return basicPicInfoService.deleteBasicPicInfoById(id);
    }

}
